<@sp.pagehead shiroUserHelper.getCurrentShiroUser().parentSources />
<div class="panel panel-inverse" data-sortable-id="form-validation-1">
    <div class="panel-heading">
        <h4 class="panel-title">账户表单</h4>
    </div>
    <div class="panel-body">
        <form class="form-horizontal form-bordered" id="accountAddForm" name="accountAddForm" action="" method="post">
            <div class="form-group">
                <label class="control-label col-md-3 col-sm-3">账户名称 *</label>
                <div class="col-md-7 col-sm-7">
                    <input type="text" id="accountName" class="form-control" name="accountName" placeholder="账户名称 2-20位"
                           rangelength="2,20" required>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-md-3 col-sm-3">真实姓名 *</label>
                <div class="col-md-7 col-sm-7">
                    <input type="text" id="realName" class="form-control" name="realName" placeholder="真实姓名 最长20位"
                           maxlength="20" required>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-md-3 col-sm-3">账户密码 *</label>
                <div class="col-md-7 col-sm-7">
                    <input type="password" id="password" class="form-control" name="password" value=""
                           placeholder="密码 6-12位" rangelength="6,12" required>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-md-3 col-sm-3">确认密码 *</label>
                <div class="col-md-7 col-sm-7">
                    <input type="password" id="confirmPassword" class="form-control" name="confirmPassword" value=""
                           placeholder="密码 6-12位" rangelength="6,12" required>
                </div>
            </div>
            <!--<div class="form-group">-->
            <!--<label class="control-label col-md-3 col-sm-3">所属平台 *</label>-->
            <!--<div class="col-md-7 col-sm-7">-->
            <!--<select class="form-control" name="platform" id="platform" required>-->
            <!--<option value="">-&#45;&#45;全平台-&#45;&#45;</option>-->
            <!--<#if platforms?has_content && platforms?exists>-->
            <!--<#list platforms as pf>-->
            <!--<option value="${pf.id}">${pf.name}</option>-->
            <!--</#list>-->
            <!--</#if>-->
            <!--</select>-->
            <!--</div>-->
            <!--</div>-->
            <div class="form-group">
                <label class="control-label col-md-3 col-sm-3">分配角色</label>
                <div class="col-md-7 col-sm-7">
                    <@sp.tree actionUrl="${rc.contextPath}/duty/tree" title="分配角色" selected=""/>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-md-3 col-sm-3"></label>
                <div class="col-md-7 col-sm-7">
                    <button type="button" id="accountAddSubmitButton" class="btn btn-sm btn-success">提交</button>
                    <button type="button" class="btn btn-sm btn-default"
                            onclick="getData('${rc.contextPath}/user/query','${shiroUserHelper.getCurrentShiroUser().parentMenuSource.name}')">
                        返回
                    </button>
                </div>
            </div>
        </form>
    </div>
</div>
<script type="application/javascript">

    $(function () {

        $('#accountAddSubmitButton').click(function () {
            $('#accountAddForm').submit();
        })

        $('#accountAddForm').validate({
            rules: {
                accountName: {
                    accountCheck: true,
                    byteRangeLength: [2, 20]
                },
                confirmPassword: {
                    equalTo: "#password"
                }
            },
            messages: {
                accountName: {
                    rangelength: "长度为2-20的字母\\数字\\下划线\\点"
                }
            },
            errorPlacement: function (error, element) {
                error.appendTo(element.parent());
            },
            submitHandler: function () {
                var selectNode = $.selectedTreeNode();
                postDataByFormParams('${rc.contextPath}/user/add', '${shiroUserHelper.getCurrentShiroUser().parentMenuSource.name}', 'accountAddForm', selectNode);
            }
        })
    })
</script>

